/*-----------------------------------------------------------------------------
	The contents of this file are subject to the Mozilla Public License
	Version 1.1 (the "License"); you may not use this file except in
	compliance with the License. You may obtain a copy of the License at
	http://www.mozilla.org/MPL/
	
	Software distributed under the License is distributed on an "AS IS"
	basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
	License for the specific language governing rights and limitations
	under the License.
	
	The Original Code is Fever Framework code.
	
	The Initial Developer of the Original Code is Romain Ecarnot.
	Portions created by Initial Developer are Copyright (C) 2006
	the Initial Developer. All Rights Reserved.
	
	Contributor(s):
	
	Unless required by applicable law or agreed to in writing, software
	distributed under the License is distributed on an "AS IS" BASIS,
	WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
	See the License for the specific language governing permissions and
	limitations under the License.
-----------------------------------------------------------------------------*/

import org.aswing.Component;
import org.aswing.JScrollPane;
import org.aswing.JTextArea;

import fvaswing.components.forms.FvStringField;

/**
 * Textarea form field.
 * 
 * <p>Allow user to place a textarea field into form.<br />
 * Email validation is done using {@link fever.data.validators.StringValidator} validator.<br />
 * You can customize validation using {@link #FvStringAreaField()} constructor.
 * 
 * <p>Example
 * {@code
 *   var areaField : FvStringAreaField = new FvStringAreaField( "Message", 1, 255 );
 * }
 *  
 * @author Romain Ecarnot
 */
class fvaswing.components.forms.FvStringAreaField extends FvStringField
{
	//-------------------------------------------------------------------------
	// Private properties
	//-------------------------------------------------------------------------
	
	private var _input : JTextArea;
	private var _rows : Number;
	
	
	//-------------------------------------------------------------------------
	// Public Properties
	//-------------------------------------------------------------------------
	
	/** Default rows value for created <strong>JTextArea</strong> component. */
	public static var DEFAULT_AREA_ROWS : Number = 5;
		
	
	//-------------------------------------------------------------------------
	// Public API
	//-------------------------------------------------------------------------
	
	/**
	 * Constructor.
	 * 
	 * @param label Field caption
	 * @param rows Number of rows for textarea component
	 * @param minLength Minimum length for password value
	 * @param maxLength Maximum length for password value
	 */
	public function FvStringAreaField( label : String, rows : Number, minLength : Number, maxLength : Number )
	{
		super( label, minLength, maxLength );
		
		_rows = ( rows != undefined ) ? rows : DEFAULT_AREA_ROWS;
	}
	
	
	//-------------------------------------------------------------------------
	// Private implementation
	//-------------------------------------------------------------------------
	
	private function _createValueComponent() : Component
	{
		_input = new JTextArea( "", _rows );
		var scroll : JScrollPane = new JScrollPane( _input );
				
		return scroll;
	}
		
}